import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';

import createAutoImport from './modules/auto-import';
import createSvgIcon from './modules/svg-icon';
import createCompression from './modules/compression';
import createSetupExtend from './modules/setup-extend';
import createElementPlusPlugin from './modules/element-plus';
import createEsLintPlugin from './modules/eslint-plugin';

export default function createVitePlugins(viteEnv, path, isBuild = false) {
  const vitePlugins = [vue(), vueJsx()];
  vitePlugins.push(createSetupExtend());
  vitePlugins.push(createElementPlusPlugin());
  vitePlugins.push(createSvgIcon(isBuild));
  vitePlugins.push(createEsLintPlugin());
  vitePlugins.push(createAutoImport(path));
  if (isBuild) {
    vitePlugins.push(...createCompression(viteEnv));
  }
  return vitePlugins;
}
